﻿using System.Security.Claims;
using Flickr.Owin.Security.Constants;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Provider;

namespace Flickr.Owin.Security
{
    public class FlickrAuthenticatedContext : BaseContext
    {
        public string AccessToken { get; private set; }
 
        public string AccessTokenSecret { get; private set; }

        public string FullName { get; private set; }

        /// <summary>
        /// Initializes a <see cref="FlickrAuthenticatedContext"/>
        /// </summary>
        /// <param name="context">The OWIN environment</param>
        /// <param name="identity">The <see cref="ClaimsIdentity"/> representing the user</param>
        /// <param name="properties">A property bag for common authentication properties</param>
       public FlickrAuthenticatedContext(
            IOwinContext context,
            ClaimsIdentity identity,
            AuthenticationProperties properties
            )
            : base(context)
        {
            Identity = identity;
            Properties = properties;
            AccessToken = Identity.FindFirst(FlickrClaimsTypes.AccessToken).Value;
            AccessTokenSecret = Identity.FindFirst(FlickrClaimsTypes.AccessTokenSecret).Value;
            FullName = Identity.FindFirst(FlickrClaimsTypes.FullName).Value;
       }

        /// <summary>
        /// Gets or sets the <see cref="ClaimsIdentity"/> representing the user
        /// </summary>
        public ClaimsIdentity Identity { get; set; }

        /// <summary>
        /// Gets or sets a property bag for common authentication properties
        /// </summary>
        public AuthenticationProperties Properties { get; set; }
        
    }
}